package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties("handler")
//攻略分类
public class StrategyCatalog extends BaseDomain {
    public static final boolean STATE_ENABLE = true; //启用
    public static final boolean STATE_DISABLE = false; //禁用

    private String name; //名称

    private Long strategyId; //大攻略ID
    private String strategyTitle; //大攻略标题

    private Integer sequence; //序列

    private boolean state = STATE_ENABLE; //状态,默认启用

    //封装当前分类中的文章
    private List<StrategyDetail> details = new ArrayList<>();

    public String getStateName() {
        String msg = "启用";
        if (state == STATE_DISABLE) {
            msg = "禁用";
        }
        return msg;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("strategyId", strategyId);
        map.put("sequence", sequence);
        map.put("state", state);
        return JSONUtil.toJSONString(map);
    }
}